<?php
/**
 * User: Administrator
 * Email: aphie1900@sina.com
 * Date & Time: 2017/9/14 0014 16:20
 */

namespace app\api\validate;


class IDCollection extends BaseValidate
{
    protected $rule = [
        'ids' => 'require|checkIDs'
    ];

    protected $message = [
        'ids' => 'ids必须是以逗号分隔的正整数'
    ];

    public function checkIDs($ids)
    {
        $arr = explode(',', $ids);
        if (empty($arr)) {
            return false;
        }
        foreach ($arr as $id) {
            if (!$this->isPositiveInteger($id)) {
                return false;
            }
        }
        return true;
    }
}